const express = require('express')
const pool = require('../pool')
const router = express.Router()
module.exports = router
router.get('/detail', (req, res, next) => {
	//获取get请求的数据
	var $id = req.query.d_caid;
	if (!$id) {
		res.send({
			code: 401,
			msg: 'id required'
		});
		return;
	}
	//响应查询到的详情页轮播对象
	pool.query('SELECT * FROM xh_detail_carousel WHERE d_caid=?', [$id], (err, result1) => {
		if (err) {
			next(err);
			return;
		}
		// 详情页景点数据
		pool.query('SELECT * FROM xh_detail_pic WHERE d_pid=?', [$id], (err, result2) => {
			if (err) {
				next(err)
				return
			}
			// 预约票价规格
			pool.query('SELECT * FROM xh_detail WHERE did=?', [$id], (err, result3) => {
				if (err) {
					next(err)
					return
				}
				res.send({
					code: 200,
					message: '操作成功',
					banner: result1,
					detailPic:result2,
					scenicDetail:result3
				})
			})
		})
	})
})
